package zyd.springboot.springbootmybatis.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import zyd.springboot.springbootmybatis.entity.User;
import zyd.springboot.springbootmybatis.service.UserServiceDemo;
@RestController
public class UserControllerDemo {
    @Autowired
    private UserServiceDemo userServiceDemo;
    @RequestMapping("/registDemo")
    public String registDemo(){
        User user=new User();
        user.setUsername("孙猴子22");
        user.setPassword("123456");
        user.setAge(12);
        boolean result=userServiceDemo.registDemo(user);
        if(result){
            return "注册成功";
    }
        else {
            return "注册失败";
        }
    }
    @RequestMapping("/loginDemo")
    public String loginDemo(){
        User user=new User();
        user.setUsername("孙猴子22");
        user.setPassword("12345");
        user.setAge(12);
        User result=userServiceDemo.loginDemo(user);
        if(result!=null){
            return "登陆成功";
        }
        else {
            return "登陆失败";
        }
    }
}
